package com.sikaryofficial.backend.constant;

import com.sikaryofficial.common.core.constant.PointRuleConstant;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 活动类型枚举
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum ActivityTypeEnum {

    /**
     * 1-purchase 抢购
     */
    PURCHASE(1, "purchase", "积分预约0元定时抢购"),
    /**
     * 2-lottery 抽奖
     */
    LOTTERY_TURNTABLE(2, PointRuleConstant.LOTTERY_TURNTABLE, "积分抽奖(幸运大转盘)"),
    /**
     * 3-auction 刮刮乐
     */
    LOTTERY_SCRATCH(3, PointRuleConstant.LOTTERY_SCRATCH, "刮刮乐"),
    /**
     * 4-立即活动
     */
    PURCHASE_ACTIVATE_NOW(4, "purchase_activate_now", "积分抽奖--定时开奖，预约即参与活动，中奖邮件通知");

    private final Integer code;
    private final String name;
    private final String desc;

    public static ActivityTypeEnum getNameByCode(Integer code) {

        return Arrays.stream(ActivityTypeEnum.values())
                .filter(pointRuleEnum -> Objects.nonNull(code) && pointRuleEnum.getCode().equals(code))
                .findFirst().orElse(null);

    }

}
